<?php

/**
 * @author Eureka
 */
class AdminController extends CController
{

	public $breadcrumbs = array();
	public $menus = array();
	public $layout = 'column2';

	public function init()
	{
		$this->layout = 'admin';
	}

	//put your code here
	public function actionIndex()
	{
		$this->render('index', array());
	}

	public function actionCreate_Shop()
	{
		$this->menus = array('label' => 'Tạo cửa hàng mới', 'url' => array('admin/create_shop'));

		$model = new Shops();

		if (isset($_POST['Shops']))
		{
			$model->setAttributes($_POST['Shops']);
			
			if ($model->validate() && $model->save())
			{
				Yii::app()->user->setFlash('success', 'Bạn đã thêm shop mới thành công');
			}
			else
			{
				Yii::app()->user->setFlash('error', 'Có lỗi xảy ra');
			}
		}

		$this->render('create_shop', array(
			'model' => $model
		));
	}

	public function actionCreate_Item()
	{
		$this->menus = array('label' => 'Tạo sản phẩm mới', 'url' => array('admin/create_item'));

		$model = new Items;

		$this->render('create_item', array(
			'model' => $model
		));
	}

	public function actionItems()
	{
		$this->render('items', array(
		));
	}

	public function actionShops()
	{
		$this->render('shops', array(
		));
	}

}
